﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _06继承与多态案例
{
    
    class Weapon
    {
        protected string _name;
        protected int _ammoNubInMc;     //载弹数量
        protected int _magazineCapacity;     //弹匣容量
        protected float _attackRange;   //攻击范围
        protected float _fireRate;       //射速
        protected int _totalAmmoNum;
        
        public int MagzineCapacity { get { return _magazineCapacity; }
            set { _magazineCapacity = value; }
        }

        public int AmmoNubInMc { get { return _ammoNubInMc; }
            set { _ammoNubInMc = value; }
        }



        public Weapon(string name,int magCa, int ammo,float rate,float attackRange)
        {
            _name = name;
            MagzineCapacity = magCa;
            AmmoNubInMc = ammo;
            _fireRate = rate;
            _attackRange = attackRange;
        }

        public virtual void Fire() 
        {
            //Console.WriteLine("基类的开火方法，不实现任何功能。");

            if(AmmoNubInMc<=0)
            {
                AmmoNubInMc--;
            }else
            {
                Reload();
            }
        }

        //更换弹匣
        public void Reload()
        {
            //Console.WriteLine("基类的上弹方法，不实现任何功能。");
            _totalAmmoNum += _ammoNubInMc;
            AmmoNubInMc = MagzineCapacity;
            _totalAmmoNum -= AmmoNubInMc;

        }

        public virtual void PrintWeaponStatus()
        {
            Console.WriteLine("----------武器状态栏-----------");
            Console.WriteLine("武器名称：{0}",_name);
            Console.WriteLine("弹药/弹匣：{0}/{1}", _ammoNubInMc,MagzineCapacity);
        }



    }
}
